<?php
class Detail extends CI_Controller {

    function __construct() {
        parent::__construct();
        $this->load->helper('url');
        $this->load->helper('date');
        if (file_exists('application/controllers/install.php'))
            redirect('install');
        $this->load->model('works_model');
        $this->load->model('college_model');
        $this->load->model('poll_model');
        $this->load->library('session');

    }

    function index() {
        $data['title'] = '作品详情';
        $data['query'] = $this->works_model->select();
        if (empty($data['query'])) { // if pid not existed, redirect
            $data['title'] = '出错啦';
            $data['words'] = '查询id错误';
            $this->load->view('templates/header', $data);
            $this->load->view('poster_admin/404', $data);
            $this->load->view('templates/footer', $data);
        } else {
            $id = $data['query']['college'];
            $data['polls'] = $this->poll_model->count();
            $data['college'] = $this->college_model->select($id);
            $this->load->view('templates/header', $data);
            $this->load->view('detail', $data);
            $this->load->view('templates/footer', $data);
        }
    }
}